<template>
  <el-form :model="person" class="person-info">
    <div>
      <div class="person-head">
        <h3 class="person-head-text">个人中心</h3>
      </div>
      <div class="person-title">
        <p class="person-title-text">个人信息</p>
      </div>
    </div>
    <!-- 显示个人相关信息 -->
    <div style="padding-left:5px; margin: 50px;">
      <el-form-item class="" label="姓名" label-width="100px">
        <el-input v-model="person.name" style="width:600px" disabled></el-input>
      </el-form-item>
      <el-form-item label="身份证号" label-width="100px">
        <el-input v-model="person.id" style="width:600px" disabled></el-input>
      </el-form-item>
      <el-form-item label="性别" label-width="100px">
        <el-input v-model="person.sex" style="width:600px" disabled></el-input>
      </el-form-item>
      <el-form-item label="年龄" label-width="100px">
        <el-input v-model="person.age" style="width:600px" disabled></el-input>
      </el-form-item>
      <el-form-item label="房间号" label-width="100px">
        <el-input
          v-model="person.roomnumber"
          style="width:600px"
          disabled
        ></el-input>
      </el-form-item>
      <el-form-item label="楼栋号" label-width="100px">
        <el-input
          v-model="person.corridornumber"
          style="width:600px"
          disabled
        ></el-input>
      </el-form-item>
      <el-form-item label="电话号码" label-width="100px">
        <el-input
          v-model="person.telephone"
          style="width:600px"
          disabled
        ></el-input>
      </el-form-item>
    </div>
  </el-form>
</template>

<script>
export default {
  name: "PersonInfo",
  //返回新生成的组件相关数据
  data() {
    return {
      person: {
        id: "",
        name: "",
        sex: "",
        age: "",
        roomnumber: "",
        corridornumber: "",
        telephone: "",
      },
    };
  },
  //前端测试路由拦截器，查看发送的请求正确与否
  /*mounted(){
  		this.axios.interceptors.request.use(config => {
  			console.log(config)
  			return config
  		},error =>{
  			return Promise.reject(error)
  		})
  	},*/
  //生命周期钩子函数，在当前页面创建之后会引发的动作
  created() {
    //请求用户个人信息
    this.$axios
      .get("/api/personinfo/"+this.$store.state.user, {
        headers: { Authorization: "Bearer " + this.$store.state.token },
      })
      .then((response) => {
        console.log(response.data)
        var infolist = response.data.properietor;
        this.person.id = infolist[0][0];
        this.person.name = infolist[0][3];
        
        if (infolist[0][5] == 0)
          this.person.sex = "男";
        else
          this.person.sex = "男";
        this.person.age = infolist[0][4];
        this.person.roomnumber = infolist[0][6];
        this.person.corridornumber = infolist[0][7];
        this.person.telephone = infolist[0][8];
      });
  },
  methods: {},
};
</script>

<style>
/* 这里是个人信息的相关css表 */

.person-info {
  padding-left: 10px;
}
/*定义了主体结构标题*/
.person-head {
  width: 1000px;
  height: 52px;
  border-bottom: 1px solid rgb(224, 224, 224);
}
/*定义了主体结构标题的文字格式*/
.person-head-text {
  width: 160px;
  height: 52px;
  line-height: 29px;
  color: rgba(122, 112, 112, 1);
  font-size: 28px;
  font-family: SourceHanSansSC-bold;
}
/*定义了主体结构副标题*/
.person-title {
  width: 1000px;
  height: 50px;
  line-height: 20px;
  padding-left: 15px;
  background-color: rgba(224, 224, 224, 1);
  border: 1px solid rgba(224, 224, 224, 1);
}
/*定义了主体结构副标题的文字格式*/
.person-title-text {
  color: rgba(16, 16, 16, 1);
  font-size: 16px;
  font-family: SourceHanSansSC-regular;
}
</style>
